% Generation for K-L polynomials
% ------------------------------
function K_L = Zernike_to_K_L(U, ZM)
% U: matrix from singular value decomposition 
% ZM: Zernike polynomials with size: (N,N,j_max-1)
% output: 
% K_L: with size same as Z

K_L = zeros(size(ZM));
for i = 1:size(U,1) % no piston term
    for j = 1:size(U,2)
        K_L(:,:,i) = K_L(:,:,i) + U(j,i)*ZM(:,:,j);
    end
end

% end of function
end

